<!DOCTYPE html>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
    <head>
    <th:block th:include="include :: head('首页')" />
</head>
<body>

    <form id="demoSingleTableForm" novalidate=true th:object="${demoSingle}">
        <input name="id" th:field="*{id}"  type="hidden">
        <div class="form-row">
            <div class="col form-group">
                <input id="intField" name="intField" th:field="*{intField}" required class="form-control" placeholder="intField">
            </div>

            <div class="col form-group">
                <input id="varcharField"  name="varcharField" th:field="*{varcharField}" class="form-control" placeholder="varcharField" >
            </div>
        </div>
        <div class="form-row">
            <div class="col form-group">
                <input id="dateField" name="dateField" th:field="*{dateField}" required class="form-control time-input" placeholder="dateField">
            </div>

            <div class="col form-group">
                <select name="selectDictField"  th:field="*{selectDictField}"  class="form-control noselect2" >
                    <option value="" disabled selected>selectDictField</option>  
                    <option  th:selected="*{selectDictField == '0'}" value="0">0</option>
                    <option  th:selected="*{selectDictField == '1'}" value="1">1</option>
                    <option  th:selected="*{selectDictField == '2'}" value="2">2</option>
                </select>

            </div>
        </div>
        <div class="form-row">
            <div class="col form-group" >

                <input type="checkbox" name="checkDictField" class="form-control check-box"  th:checked="${#arrays.contains(demoSingle.checkDictFieldArray,  '1')}"  value="1"/>B
                <input type="checkbox" name="checkDictField" class="form-control check-box" th:checked="${#arrays.contains(demoSingle.checkDictFieldArray,  '2')}"  value="2"/>C
                <input type="checkbox" name="checkDictField" class="form-control check-box" th:checked="${#arrays.contains(demoSingle.checkDictFieldArray,  '0')}" value="0"/>A

            </div>
            <div class="col form-group">
                <input type="radio" name="redioDictField" th:checked="*{redioDictField == 'radio1'}" class="form-control radio-box" value="radio1"/>radio1
                <input type="radio" name="redioDictField" th:checked="*{redioDictField == 'radio2'}" class="form-control radio-box" value="radio2"/>radio2
            </div>
        </div>
        <div class="form-row">
            <div class="col form-group">
                <select id="multiSelectField"  name="multiSelectField" class="form-control " multiple="multiple">
                    <option  th:selected="*{#arrays.contains(multiSelectFieldArray, '0')}" value="0">0</option>
                    <option th:selected="*{#arrays.contains(multiSelectFieldArray, '1')}" value="1">1</option>
                    <option th:selected="*{#arrays.contains(multiSelectFieldArray,  '2')}"  value="2">2</option>

                </select>
            </div>
        </div>

    </form>
    <div th:replace="include :: footer"></div>
    <script type="text/javascript">
        var prefix = "/singleTable";
        $("#demoSingleTableForm").validate({
            rules: {
                intField: {
                    required: true,
                    digits: true
                },
                varcharField: {
                    required: true,
                }
            }
        });

        function submitHandler() {
            if ($.validate.form()) {
                var data = $("#demoSingleTableForm").serializeArray();
                $.operation.saveModal(prefix + "/add", data, function () {
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭  
                    parent.SampleTable.table.refresh();
                });
            }
        }
    </script>
</body>
</html>